<?php
class page_model extends CI_Model{
		public $model;
		function __construct(){
			$this->model='page';
		}
		
		/*
		 * 获取单页
		 */
		public function get_page($cid){
			$query=$this->db->get_where($this->model,array('cid'=>$cid))->row_array();
			if(!empty($query)){
					if(!empty($query['photo'])){
						$query['img']=$this->db->get_where('upload',array('id'=>$query['photo']))->row_array();
					}
			}
			if(!empty($query)){
				if(!empty($query['photo1'])){
					$query['img1']=$this->db->get_where('upload',array('id'=>$query['photo1']))->row_array();
				}
			}
			if(!empty($query)){
				if(!empty($query['video'])){
					$query['vid']=$this->db->get_where('upload',array('id'=>$query['video']))->row_array();
				}
			}
			return $query;
		}
		
		/*
		 * 首页导航用图
		 */
		public function get_nav_img($cid){
			$query=$this->db->get_where($this->model,array('cid'=>$cid))->row_array();
			if(!empty($query)){
				if(!empty($query['photo'])){
					$query['img']=$this->db->get_where('upload',array('id'=>$query['photo']))->row_array();
				}
				if(!empty($query['photo1'])){
					$query['img1']=$this->db->get_where('upload',array('id'=>$query['photo1']))->row_array();
				}
				if(!empty($query['photo2'])){
					$query['img2']=$this->db->get_where('upload',array('id'=>$query['photo2']))->row_array();
				}
				if(!empty($query['photo3'])){
					$query['img3']=$this->db->get_where('upload',array('id'=>$query['photo3']))->row_array();
				}
			}
			return $query;
		}
		
		/*
		 * 获取banner图
		*/
		public function get_banner($cid){
			$query=$this->db->get_where($this->model,array('cid'=>$cid))->row_array();
			if(!empty($query['photo'])){
				$query['img']=$this->db->get_where('upload',array('id'=>$query['photo']))->row_array();
			}
			return $query;
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
}